﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Order_Print.aspx.cs" Inherits="OrderManagement_Order_Print" MasterPageFile="~/MasterPage.master" %>

<%@ Register Src="~/UserControl/PrintTempleteForOrderPrint.ascx" TagName="PrintTempleteForOrderPrint"
    TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <title>送货单打印</title>
    <script src="../JavaScript/common.js" type="text/javascript"></script>
    <script type="text/javascript">
    function printPage(divid) 
    {  
        var printarea =document.getElementById(divid);
        if(printarea==null || printarea.getAttribute('visible')==false)
            return;
        var newWin = window.open('Order_Printer.htm','',''); 
        var titleHTML = printarea.innerHTML;   
        var re=new RegExp('"TEXT-ALIGN: center"',"g");
        //把打印按钮隐藏
        titleHTML = titleHTML.replace(re,'"display:none;"');
        newWin.document.write("<div style=' text-align: center;'>" + titleHTML + "</div>"); 
        newWin.document.location.reload();
    } 
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<script type="text/javascript">
    function formatDate(v) {
        if (v instanceof Date) {
            var y = v.getFullYear();
            var m = v.getMonth() + 1;
            var d = v.getDate();
            var h = v.getHours();
            var i = v.getMinutes();
            var s = v.getSeconds();
            var ms = v.getMilliseconds();
            if (ms > 0)
                return y + '-' + m + '-' + d + ' ' + h + ':' + i + ':' + s
						+ '.' + ms;
            if (h > 0 || i > 0 || s > 0)
                return y + '-' + m + '-' + d + ' ' + h + ':' + i + ':' + s;
            return y + '-' + m + '-' + d;
        }
        return '';
    }

    $(function () {
        $('#<%=txtDate.ClientID %>').datebox({
            currentText: '今天',
            closeText: '关闭',
            disabled: false,
            required: true,
            missingMessage: '必填',
            formatter: formatDate
        });
    });
     
</script>
    <div>
        <table id="wsd_inputtable">
            <tr>
                <td class="tabletitle" colspan="4">
                    <span class="keyword">提示:*为必填项</span>
                </td>
            </tr>
            <tr>
                <td class="tablefield">
                    <span class="keyword">*</span>组织架构
                </td>
                <td nowrap="nowrap">
                    <asp:TextBox ID="txtOrg" runat="server" onkeydown="alert('请选择组织架构');return false;"
                        OnTextChanged="txtOrg_TextChanged"  class="default"></asp:TextBox>
                    <img  id="imgOrg" src="../Resources/Images/search.png" alt="查找" style="cursor: pointer;" 
                        onclick="openPopup('../System/PopupOrganization.aspx?NameControlId=<%# txtOrg.UniqueID %>&ValueControlId=<%# txtHidOrg.UniqueID %>&ChainsControlID=<%# txtHidChains.UniqueID %>&SelectType=multi','','300','500');" />
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="请选择组织架构!"
                        ControlToValidate="txtOrg"></asp:RequiredFieldValidator>
                </td>
                <td class="tablefield">
                    门店名称
                </td>
                <td nowrap="nowrap">
                    <asp:TextBox runat="server" ID="txtName" MaxLength="20" Width="150px" class="default"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="tablefield">
                    订单日期
                </td>
                <td>
                    <input id="txtDate" type="text" runat="server"   readonly="readonly"
            class="default" style="width:150px;"       />
                </td>
                <td class="tablefield">
                    经销商名称
                </td>
                <td>
                    <asp:DropDownList ID="ddlChains" runat="server" Width="150">
                        <asp:ListItem Value="">--所有--</asp:ListItem>
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td class="tablefield">
                    销售代表
                </td>
                <td>
                    <asp:DropDownList ID="ddlMobileUsers" runat="server" Width="150">
                        <asp:ListItem Value="">--所有--</asp:ListItem>
                    </asp:DropDownList>
                </td>
                <td class="buttonarea" colspan="3">
                    <input id="txtHidOrg" type="hidden" runat="server" />
                    <input id="txtHidChains" type="hidden" runat="server" />
                </td>
            </tr>
        </table>
        <br />
        <div runat="server" id="PrintArea" visible="true">
            <table id="wsd_printtable">
                <tr>
                    <td class="tabletitle">
                        销售订单预览
                    </td>
                </tr>
                <tr>
                    <td style="text-align: left">
                        <!-----------  打印内容开始  ---------->
                        <div id="printdiv" style="padding: 0 0 0 0; margin: 2 0 0 2; text-align: left">
                            <center>
                                <asp:Panel ID="panelx" runat="server">
                                </asp:Panel>
                            </center>
                        </div>
                        <!-----------  打印内容结束  ---------->
                    </td>
                </tr>
            </table>
        </div>
        <br />
        <table id="wsd_inputtable">
            <tr>
                <td class="tabletitle">
                    操作选项
                </td>
            </tr>
            <tr>
                <td class="buttonarea">
                    <asp:Button ID="btnSearch" runat="server" Text="预  览" class="wsd_button2" OnClick="btnSearch_Click" />
                    &nbsp;<input id="Button1" type="button" value="全部打印" class="wsd_button2" onclick="printPage('printdiv');" />
                    <asp:Button ID="btnExport" runat="server" class="wsd_button2" Text="导出Excel" OnClick="btnExport_Click" />
                </td>
            </tr>
        </table>
    </div>
</asp:Content>
